package com.worldcup.model.dto;

import com.worldcup.model.PredictKnockout;
import com.worldcup.service.impl.CountryServiceImpl;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author duwan.zq
 * @date 2018/06/02
 */
@Getter
@Setter
@NoArgsConstructor
public class PredictTypeKnockoutDTO  implements Serializable {

    private Integer matchType;

    private List<PredictKnockoutDTO> matches;

    public PredictTypeKnockoutDTO(Integer matchType, List<PredictKnockout> predictKnockouts) {
        this.matchType = matchType;
        if(predictKnockouts == null){
            return;

        }
        this.matches = new ArrayList<>(predictKnockouts.size());
        predictKnockouts.forEach(predictKnockout -> this.matches.add(new PredictKnockoutDTO(predictKnockout,
            CountryServiceImpl.getCountryCache(predictKnockout.getHomeCountryId()), CountryServiceImpl.getCountryCache(predictKnockout.getAwayCountryId()))));
    }

    @Override
    public String toString(){
        return super.toString();
    }
}
